<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>分配给商店的最多商品的最小值</title>
</head>
<body>
  <script>
    function fn(n, arr) {
      arr = arr.sort((a, b) => b - a);
      let l = 1;
      let r = arr[0];
      while (l < r) {
        let mid = (l + r) >> 1;
        if (checker(mid)) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }
      function checker(num) {
        let tmp = 0;
        for (let i = 0; i < arr.length; i++) {
          tmp += Math.ceil(arr[i] / num)
        }
        return tmp <= n
      }
      return l
    }
    console.log(fn(6, [11, 6]))
  </script>
</body>
</html>